package com.neusoft.di.dibuy.demo1;

import com.neusoft.di.dibuy.util.DiTools;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.IOException;
import java.time.Duration;

public class DemApp1 {

    public static void main(String[] args) throws IOException {
        Flux.just(1,2,3,4)
                .delayElements( Duration.ofSeconds(1) )
                .doOnEach( integerSignal -> {
                    if (integerSignal.get() > 2){
                        integerSignal.isOnComplete();
                    }
                } )
                .doOnComplete(() -> System.out.println("complete"))
                .doOnCancel(() -> System.out.println("cancel"))
                .doOnNext(System.out::println)
                .subscribe();
        System.in.read();
    }

    public static void main1(String[] args) {
        Mono.just(1)
                .map(DiTools.fullPrex1)
                .subscribe(System.out::println);

    }

    public static void main_Flus(String[] args) throws InterruptedException {

        Flux<Integer> just = Flux.just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);



        just.subscribe(System.out::println);
        just.subscribe(System.out::println);


        Flux.interval(Duration.ofSeconds(1) ).subscribe(System.out::println);



        Thread.sleep(99999);
        System.out.println("hello world");
    }
}
